/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * vista_ordenes.java
 *
 * Created on 10/04/2011, 05:29:28 PM
 */

package vistas;
import controladores.controlador_ordenes;
import controladores.controlador_productos;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JSpinner;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

public class vista_ordenes extends javax.swing.JFrame {

      DefaultTableModel modelo_tabla= new DefaultTableModel();

    /** Creates new form vista_producto */
    public vista_ordenes() {
        initComponents();
        jTable_ordenes.setModel(modelo_tabla);
         Vector<String> a  = new Vector<String>();
         a.add("producto");
         a.add("cantidad");
         a.add("precio");
         modelo_tabla.setColumnIdentifiers(a);
         listen_botones();
         cancelar();
    }

      public void cancelar()
    {
        modelo_tabla.setRowCount(0);
        jtxt_nombre.setText("");


    }

    public  void listen_botones()
    {
        controlador_ordenes co = new controlador_ordenes(this);
          co.cargar_producto();
        boton_mas.addActionListener (co);
        boton_mas.setActionCommand("mas");
        boton_menos.addActionListener(co);
        boton_menos.setActionCommand("menos");
        boton_registrar.addActionListener(co);
        boton_registrar.setActionCommand("registrar");
        
    }

    public JButton getBoton_mas() {
        return boton_mas;
    }

    public void setBoton_mas(JButton boton_mas) {
        this.boton_mas = boton_mas;
    }

    public JButton getBoton_menos() {
        return boton_menos;
    }

    public void setBoton_menos(JButton boton_menos) {
        this.boton_menos = boton_menos;
    }

    public JButton getBoton_registrar() {
        return boton_registrar;
    }

    public void setBoton_registrar(JButton boton_registrar) {
        this.boton_registrar = boton_registrar;
    }

    public JComboBox getCmb_producto() {
        return cmb_producto;
    }

    public void setCmb_producto(JComboBox cmb_producto) {
        this.cmb_producto = cmb_producto;
    }

    public JTable getjTable_ordenes() {
        return jTable_ordenes;
    }

    public void setjTable_ordenes(JTable jTable_ordenes) {
        this.jTable_ordenes = jTable_ordenes;
    }

    public JTextField getJtxt_nombre() {
        return jtxt_nombre;
    }

    public void setJtxt_nombre(JTextField jtxt_nombre) {
        this.jtxt_nombre = jtxt_nombre;
    }

    public JTextField getJtxt_total() {
        return jtxt_total;
    }

    public void setJtxt_total(JTextField jtxt_total) {
        this.jtxt_total = jtxt_total;
    }

    public JSpinner getJtxtcantidad() {
        return jtxtcantidad;
    }

    public void setJtxtcantidad(JSpinner jtxtcantidad) {
        this.jtxtcantidad = jtxtcantidad;
    }

    public DefaultTableModel getModelo_tabla() {
        return modelo_tabla;
    }

    public void setModelo_tabla(DefaultTableModel modelo_tabla) {
        this.modelo_tabla = modelo_tabla;
    }



    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        jtxt_nombre = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        cmb_producto = new javax.swing.JComboBox();
        boton_mas = new javax.swing.JButton();
        boton_menos = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable_ordenes = new javax.swing.JTable();
        boton_registrar = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jtxtcantidad = new javax.swing.JSpinner();
        jLabel8 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jtxt_total = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(null);

        jLabel2.setText("Cliente");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(10, 90, 90, 18);
        getContentPane().add(jtxt_nombre);
        jtxt_nombre.setBounds(100, 80, 240, 28);

        jLabel6.setText("producto");
        getContentPane().add(jLabel6);
        jLabel6.setBounds(10, 120, 120, 20);

        cmb_producto.setModel(new javax.swing.DefaultComboBoxModel(new String[] {}));
        cmb_producto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmb_productoActionPerformed(evt);
            }
        });
        getContentPane().add(cmb_producto);
        cmb_producto.setBounds(100, 120, 410, 30);

        boton_mas.setText("+");
        boton_mas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_masActionPerformed(evt);
            }
        });
        getContentPane().add(boton_mas);
        boton_mas.setBounds(530, 120, 40, 30);

        boton_menos.setText("-");
        getContentPane().add(boton_menos);
        boton_menos.setBounds(580, 120, 40, 30);

        jTable_ordenes.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "producto", "precio", "cantidad"
            }
        ));
        jScrollPane1.setViewportView(jTable_ordenes);

        getContentPane().add(jScrollPane1);
        jScrollPane1.setBounds(10, 160, 780, 330);

        boton_registrar.setText("registrar");
        getContentPane().add(boton_registrar);
        boton_registrar.setBounds(310, 500, 150, 40);

        jLabel9.setFont(new java.awt.Font("Ubuntu", 0, 24)); // NOI18N
        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel9.setText("Registrar Ordenes");
        getContentPane().add(jLabel9);
        jLabel9.setBounds(250, 10, 290, 40);
        getContentPane().add(jtxtcantidad);
        jtxtcantidad.setBounds(710, 120, 40, 28);

        jLabel8.setText("cantidad");
        getContentPane().add(jLabel8);
        jLabel8.setBounds(630, 120, 120, 20);

        jLabel1.setText("Total a pagar");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(470, 520, 280, 18);

        jtxt_total.setEditable(false);
        getContentPane().add(jtxt_total);
        jtxt_total.setBounds(600, 510, 160, 50);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-802)/2, (screenSize.height-630)/2, 802, 630);
    }// </editor-fold>//GEN-END:initComponents

    private void cmb_productoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmb_productoActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_cmb_productoActionPerformed

    private void boton_masActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_masActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_boton_masActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new vista_ordenes().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton boton_mas;
    private javax.swing.JButton boton_menos;
    private javax.swing.JButton boton_registrar;
    private javax.swing.JComboBox cmb_producto;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable_ordenes;
    private javax.swing.JTextField jtxt_nombre;
    private javax.swing.JTextField jtxt_total;
    private javax.swing.JSpinner jtxtcantidad;
    // End of variables declaration//GEN-END:variables

}
